package com.yanqu.road.server.cmd.cricket.court;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cricket.CricketProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.cricket.CricketModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_CRICKET_TOP_RANK_WORSHIP, desc = "蛐蛐宗师榜排行榜膜拜")
public class CricketTopRankWorshipCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CricketProto.CricketTopRankWorshipReqMsg reqMsg = CricketProto.CricketTopRankWorshipReqMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(CricketModule.class).worship();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            CricketProto.CricketTopRankWorshipRespMsg.Builder respMsg = CricketProto.CricketTopRankWorshipRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_CRICKET_TOP_RANK_WORSHIP, respMsg);
        }
    }
}
